import * as types from "./mutation-types";
import Api from "api/api";

const state = {
  suggestList: {},
  suggestLists: {},
  currentSuggest: {}
};

const getters = {
  suggestList: state => state.suggestList,
  suggestLists: state => state.suggestLists,
  currentSuggest: state => state.currentSuggest
};

const actions = {
  // 建言献策列表
  suggestListUsingPOSTS({ commit }, param) {
    return Api.suggestListUsingPOST(param).then(ret => {
      commit(types.UPDATE_SUGGEST_LIST, ret.data);
      return ret;
    });
  },
  // 建言献策详情
  getSuggestDetailUsingPOSTS({ commit }, param) {
    return Api.getSuggestDetailUsingPOST(param).then(ret => {
      commit(types.UPDATE_SUGGEST_LISTS, ret.data);
      return ret;
    });
  },
  // // 建言献策审核
  // examineMailBoxUsingPOSTS({ commit }, param) {
  //   return Api.examineMailBoxUsingPOST(param).then(ret => {
  //     return ret;
  //   });
  // },
  // 建言献策删除
  delSuggestUsingPOSTS({ commit }, param) {
    return Api.delSuggestUsingPOST(param).then(ret => {
      return ret;
    });
  }
};

const mutations = {
  [types.UPDATE_SUGGEST_LIST](state, payload) {
    state.suggestList = payload;
  },
  // [types.INIT_CURRENT_COLUMN](state) {
  //   state.currentColumn = {
  //     name: "",
  //     sort: 0
  //   };
  // },
  // [types.UPDATE_CURRENT_COLUMN](state, payload) {
  //   state.currentColumn = payload;
  // },
  [types.UPDATE_SUGGEST_LISTS](state, payload) {
    state.suggestLists = payload;
  }
};

export default {
  state,
  getters,
  actions,
  mutations
};
